<?php
require("../inc/common.inc.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1 " name="viewport">
<title>幸运大转盘-<?php echo $webdb["vpp_jigoucode"]?></title>
<meta name="keywords" content="幸运大转盘,<?php echo $webdb["vpp_jigoucode"]?>" />
<meta name="description" content="幸运大转盘,<?php echo $webdb["vpp_jigoucode"]?>" />
<link href="../images/style.css" rel="stylesheet" type="text/css" />
<?php $head_hide=1;require("../w_head.php");?>
<style type="text/css">
.demo{width:100%; height:auto; position:relative; padding:10px auto; background:url(bg.png) center -150px no-repeat; overflow:hidden;}
#disk{width:100%; text-align:center;}
#start{width:100%; height:auto; position:absolute; top:0px; left:0px; text-align:center;}
#start img{cursor:pointer}
.dzp_title1{ color:#FFFFFF; background:#63c2ea; line-height:200%; font-size:1.4em; text-align:center; width:95%; margin:auto; padding:0px;}
.dzp_con{ background:#17a6e0; width:95%; margin:auto; color:#FFFFFF; font-size:1.1em;-moz-border-radius:9px;-webkit-border-radius:9px;}
.dzp_con .con1{ width:95%; margin:auto;}
.dzp_con .con2{ width:95%; margin:auto; color:#fff43f;}
</style>
<?php
$sql= "select * from mx_vpp_caipiao where type='1' and isok='1' and startdate<='".date("Y-m-d")."' and enddate>='".date("Y-m-d")."' order by orderid asc,createdate desc,id desc limit 1";
$rsdb= $db -> getinfo($sql);
if ($rsdb['id']<=0) {
	$sql= "select * from mx_vpp_caipiao where type='1' and isok='1' and startdate>='".date("Y-m-d")."' and enddate>='".date("Y-m-d")."' order by startdate asc,createdate desc,id desc limit 1";
	$rsdb= $db -> getinfo($sql);
}
?>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jQueryRotate.2.2.js"></script>
<script type="text/javascript" src="jquery.easing.min.js"></script>
<script type="text/javascript">
//$(function(){
//	$("#startbtn").rotate({
//		bind:{
//			click:function(){
//				var a = Math.floor(Math.random() * 360);
//				 $(this).rotate({
//					 	duration:3000,
//					 	angle: 0, 
//            			animateTo:1440+a,
//						easing: $.easing.easeOutSine,
//						callback: function(){
//							alert('中奖了！');
//						}
//				 });
//			}
//		}
//	});
//});

$(function(){ 
     $("#startbtn").click(function(){
        lottery(); 
    }); 
}); 
function lottery(){ 
    $.ajax({ 
        type: 'POST', 
        url: 'get_dazhuanpan.php?id=<?php echo $rsdb['id'] ?>', 
        dataType: 'json', 
        cache: false, 
        error: function(){ 
            alert('出错了！'); 
            return false; 
        }, 
        success:function(json){ 
            //$("#startbtn").unbind('click').css("cursor","default"); 
            var a = json.angle; //角度 
            var p = json.prize; //奖项 
			var error = json.error;
			if (error != 0) {
				alert(error);
			} else {
				$("#startbtn").rotate({ 
					duration:3000, //转动时间 
					angle: 0, 
					animateTo:1800+a, //转动角度 
					easing: $.easing.easeOutSine, 
					callback: function(){ 
						alert(p); 
						return true;
//						if(con){ 
//							lottery(); 
//						}else{ 
//							return false; 
//						} 
					} 
				});	
			} 
        } 
    }); 
} 
</script>
</head>

<body bgcolor="#d4f3ff">
<?php
if ($rsdb["id"]>0){
?>
   <div class="demo">
        <div id="disk"><img src="<?php echo get_photourl($rsdb["picurl"])?>" width="95%"></div>
		<div id="start"><img src="start2.png" id="startbtn" width="95%"></div>
   </div>
	<div class="clear"></div>
	<div class="lingqu" style="margin-top:10px;"><a href="/my_cp.php">我的奖品</a></div>
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="dzp_con">
   
   <div class="height10"></div>
   <div class="con2">
   <table width="100%" cellpadding="0" cellspacing="0" align="center">
   <?php 
   $rs2=$db->excu("select * from  mx_vpp_caipiao_prize where cpid='$rsdb[id]' and isok='1' and isshowjp='1' order by orderid asc, createdate desc, id desc");
   if ($db->num_rows($rs2)>0){
   	while ($rsdb2=$db->fetch_array($rs2))
	{
   ?>
   <tr><td height="30"><?php echo $rsdb2["name"];?></td><td>奖品数量：<?php echo $rsdb2["shownum"];?></td></tr>
   <?php
	}
   }
   ?>
   </table>
   </div>
   <div class="height10"></div>
   </div>
   
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="height10"></div>
   <div class="clear"></div>
   
   <div class="dzp_title1">兑奖说明</div>
   <div class="dzp_con">
   <div class="height10"></div>
   <div class="height10"></div>
   <div class="clear"></div>
   <div class="con2">
   <?php echo "每次消耗".$rsdb["needintegral"]."积分<br/>";?>
   <?php echo stripslashes($rsdb["description"]);?>
   </div>
   <div class="height10"></div>
   </div>
<?php }else{?>
   <div class="demo">
        <div id="disk"><img src="images/dzpend.png" width="95%"></div>
   </div>
	<div class="clear"></div>
	<div class="lingqu" style="margin-top:10px;"><a href="/my_cp.php">我的奖品</a></div>
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="dzp_con">
   <div class="height10"></div>
   <div class="con2">
   <table width="100%" cellpadding="0" cellspacing="0" align="center">
      <tbody><tr>
        <td height="30">活动已经结束，请继续关注我们！</td>
      </tr>
      </tbody>
   </table>
   </div>
   <div class="height10"></div>
   </div>
<?php
}
require("../w_foot.php");
?>